from typing import Callable, List, Dict, Any, TypeVar

# 定义函数类型
StrProcessor = Callable[[str], str]
EventHandler = Callable[[], None]
DataTransformer = Callable[[Dict[str, Any]], List[Any]]

# 使用函数类型
def apply_formatter(text: str, formatter: StrProcessor) -> str:
    return formatter(text)

# 带泛型的Callable
T = TypeVar('T')
R = TypeVar('R')

def map_values(values: List[T], func: Callable[[T], R]) -> List[R]:
    return [func(value) for value in values]

# 使用示例
numbers = [1, 2, 3, 4]
squares = map_values(numbers, lambda x: x * x)  # [1, 4, 9, 16]